/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2021-04-09
 * Time: 16:59
 */
#include "DiagramBasePrivateText.h"


DiagramBasePrivateText::DiagramBasePrivateText(const QString &text, QGraphicsItem *parent)
        : QGraphicsTextItem(text, parent)
        , parent_item_(qgraphicsitem_cast<DiagramBaseItem *>(parent))
{
//    qDebug() << "polygon rect:" << parent_item_->polygon().boundingRect();
    this->setTextWidth(parent_item_->polygon().boundingRect().width() + 4);


    auto x = parent_item_->polygon().boundingRect().x();
    auto y = parent_item_->polygon().boundingRect().y();

    auto y_offset = (parent_item_->polygon().boundingRect().height() - this->shape().boundingRect().height()) / 2;
//    qDebug() << "x" << x << " y" << y << " y_offset" << y_offset;
    this->setPos(x - 2,y + y_offset);
}
